export SRCS_SERVER = mutexsocketlist.c serverorder.c server.c 
export SRCS_TOOLS_SERVER = toolsclientserver.c
export SRCS_LIST = list.c charlist.c intlist.c

SRC_SERVER = server/mainserver.c

export CC = gcc
export CFLAGS = -W -Wall -pedantic -ggdb -g -O3 
export LDFLAGS = -pthread 

export OBJ_DIR=obj
export OBJ_DIR_LIST=../$(OBJ_DIR)
export BIN_DIR=bin
SRC_DIR=src

FINAL_TARGET_SERVER=server

OBJS_SERVER = $(SRCS_SERVER:%.c=$(OBJ_DIR)/%.o)
OBJS_TOOLS_SERVER = $(SRCS_TOOLS_SERVER:%.c=$(OBJ_DIR)/%.o)
OBJS_TOOLS_SERVER += $(SRCS_LIST:%.c=$(OBJ_DIR)/%.o)

all: server

server: list Server
	@echo "Compilation du server"

list:
	(cd list && make list)

Server:
	(cd list && make list)
	(cd clientserver && make server)
	(cd server && make server)
	$(CC) $(CFLAGS) $(SRC_SERVER) $(OBJS_SERVER) $(OBJS_TOOLS_SERVER) -o $(BIN_DIR)/$(FINAL_TARGET_SERVER) $(LDFLAGS)

clean:
	rm -f $(OBJ_DIR)/*.o $(BIN_DIR)/$(FINAL_TARGET_SERVER)
